package DEEPERsource.DEEPERsource.source.util;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;

public class PropertyManager {

	private HashMap<String, String> param;

	public void readParam(String filename) {

		try {
			BufferedReader reader = new BufferedReader(new FileReader(filename));
			param = new HashMap<String, String>();
			String s;
			while ((s = reader.readLine()) != null) {
				// skip empty strings and comments
				if (s.equals("") || s.startsWith("//"))
					continue;
				String[] split = s.split("\t");
				if(split.length>1)
					param.put(split[0], split[1]);
				else
					throw new Exception("Parameter should contain two parts: name and value");
			}
		} catch (Exception e) {
			System.err.println("Error reading parameter " + e);
			System.exit(1);
		}

	}

	public String getParam(String key) {
		return param.get(key);
	}

}
